package jp.ac.waseda.cs.washi.game.scene;

import java.awt.Image;

import jp.ac.waseda.cs.washi.game.GameEnvironment;
import jp.ac.waseda.cs.washi.game.factory.ImageFactory;
import jp.ac.waseda.cs.washi.gameaiarena.gui.Renderer;
import jp.ac.waseda.cs.washi.gameaiarena.scene.Scene;

public class StartScene extends Scene<GameEnvironment> {
	private Image _title;
	private int _titleTime;
	private Scene<GameEnvironment> _nextScene;

	public StartScene(Scene<GameEnvironment> nextScene, int titleTime) {
		_nextScene = nextScene;
		_titleTime = titleTime;
	}

	@Override
	public Scene<GameEnvironment> run(GameEnvironment env) {
		if (--_titleTime <= 0) {
			return _nextScene;
		}
		return this;
	}

	@Override
	public void initialize(GameEnvironment env) {
		Renderer render = env.getRenderer();
		_title = ImageFactory.loadTitle(render);
		render.waitLoadImage();
	}

	@Override
	public void draw(GameEnvironment env) {
		env.getRenderer().drawImage(_title, 300, 0);
	}
}
